#pragma once
#include "Types.h"

#include "SceneObject.h"
#include "RefCount.h"
#include "MemoryStream.h"
#include "IWeapon.h"

#include <vector>
#include <map>



class CShip : public TRefCount<CShip>, public CSceneObject
{
public:
	CShip(void);
	~CShip(void);
	virtual __inline E_GAMEOBJECT_TYPE getType(){ return E_GAMEOBJECT_TYPE::Ship; } 
	virtual void passTime(f32);

	static OBJSTRMAP  deserializeShipTypeList(char *name);
	static OBJSTRMAP  deserializeShipTypeList(char *buffer, long length);
	static OBJSTRMAP  deserializeShipTypeList(irr::io::IFileReadCallBack *file);

	__inline void setAcceleration(f32 value);
	__inline f32 getAcceleration(void) { return this->mAcceleration; }
	void addWeapon(IWeapon *weapon);
	bool applyDamage(SArmor damage); // returns true if destroyed
	TContainer<IWeapon *> getWeapons(void) { return this->mWeaponList; }

	void setFiringAtTarget(E_WEAPON_MOUNTPOINT mountPoint, vector3df target);
	void fireFullMount(E_WEAPON_MOUNTPOINT mount);
	
	// utility 
	CShip *copy(void);
	
	void setMass(f32 value);
	f32	 getMass(void);

	DECLARE_MEMBER(char *, Name)
	DECLARE_MEMBER(char *, Class)
	DECLARE_MEMBER(f32, MaxNormalAcceleration)
	DECLARE_MEMBER(f32, MaxHyperAcceleration)
	DECLARE_MEMBER(vector3df, Dimensions)
	DECLARE_MEMBER(SCrewCapacity, CrewCapacity)
	DECLARE_MEMBER(SArmor, SidewallArmor)
	DECLARE_MEMBER(SArmor, HullArmor)

private:
	TContainer<IWeapon *> mWeaponList;
	f32 mMass;
};
